package com.ft.admix.bd.adapter;

import android.app.Activity;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.View;

import com.baidu.mobads.sdk.api.BaiduNativeManager;
import com.baidu.mobads.sdk.api.ExpressResponse;
import com.baidu.mobads.sdk.api.RequestParameters;
import com.kuaishou.weapon.p0.jni.A;
import com.kwad.sdk.api.KsAdSDK;
import com.kwad.sdk.api.KsFeedAd;
import com.kwad.sdk.api.KsLoadManager;
import com.kwad.sdk.api.KsScene;
import com.ft.admix.ad.MixCustomNativeAdapter;
import com.ft.admix.config.AdConfig;

import java.util.ArrayList;
import java.util.List;

public class NativeAdapterLoader extends MixCustomNativeAdapter {

    @Override
    public void load(Activity context, AdConfig config) {

        BaiduNativeManager manager = new BaiduNativeManager(context, config.getAdId());
        RequestParameters parameters = new RequestParameters.Builder().setWidth(config.getWidth())
                .setHeight(config.getHeight()).build();
        manager.loadExpressAd(parameters, new BaiduNativeManager.ExpressAdListener() {
            @Override
            public void onNativeLoad(List<ExpressResponse> list) {
                if (list != null && list.size() > 0) {
                    List<CustomBDExpressNativeAd> ads = new ArrayList<>(list.size());
                    for (ExpressResponse expressResponse : list) {
                        ads.add(new CustomBDExpressNativeAd(context, expressResponse));
                    }
                    callLoadSuccess(ads);
                }

            }

            @Override
            public void onNativeFail(int i, String s, ExpressResponse expressResponse) {
                callLoadFailed(i, s);
            }

            @Override
            public void onNoAd(int i, String s, ExpressResponse expressResponse) {
                callLoadFailed(i, s);
            }

            @Override
            public void onVideoDownloadSuccess() {

            }

            @Override
            public void onVideoDownloadFailed() {

            }

            @Override
            public void onLpClosed() {

            }
        });

    }


    @Override
    public void destroy() {
        // 清理资源
    }
} 